package cn.iocoder.yudao.module.trade.enums.orderpostback;

import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;

/**
 * 交易订单 - 状态
 *
 * @author Sin
 */
@RequiredArgsConstructor
@Getter
public enum TradeOrderPostBackStatusEnum implements IntArrayValuable {

    UN_SEND(0, "待回传"),
    FINISH(10, "已发送"),
    OFF_SHELF(20, "扣量"),
    FAILED(40, "失败"),
    RETRY_FAILED(50, "重试失败"), ;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderPostBackStatusEnum::getStatus).toArray();

    /**
     * 状态值
     */
    private final Integer status;
    /**
     * 状态名
     */
    private final String name;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    /**
     * 判断指定状态，是否正处于【已取消】状态
     *
     * @param status 指定状态
     * @return 是否
     */
    public static boolean isCanceled(Integer status) {
        return ObjectUtil.equals(status, FAILED.getStatus());
    }

}
